package com.smart.car.points.init;

import com.smart.car.common.res.constant.Constants;
import org.redisson.Redisson;
import org.redisson.api.RAtomicLong;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 初始化类
 * 优惠券可兑换数量
 */
@Order(0)
@Component
public class StartupApplicatonRunner implements ApplicationRunner {

	@Autowired
	private RedissonClient redissonClient;

	@Override
	public void run(ApplicationArguments args) throws Exception {
		RAtomicLong atomicLong = redissonClient.getAtomicLong(Constants.cache.grouponCodeAmtKey);
		atomicLong.set(Constants.cache.grouponCodeAmt);
	}
}
